
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core">

<ui:composition template="/template_padrao.xhtml">

	<ui:define name="content">

		<f:event type="preRenderView"
			listener="#{consumoMB.beginConversation()}" />


		<h2>Consulta Consumo</h2>

		<h:form id="form_con_consumo">


			<p:fieldset styleClass="fielSetPadrao">
				<legend>Pesquisa</legend>

				<div class="buttonNew">
					<p:commandButton value="Novo" action="#{consumoMB.novo()}"
						ajax="false" rendered="#{!consumoMB.administrativo}" />
						
						
					<p:commandButton value="Imprimir" action="#{consumoMB.imprimir()}"
						ajax="false" />
				</div>

				<br />
				<table class="table">
					<tr>
						<td><h:outputLabel value="Valor" title="Valor do consumo"/></td>
						<td><p:inputText value="#{consumoMB.valorPesquisa}"	converter="converterBigDecimal" /></td>
						
					</tr>

					<tr>
						<td><h:outputLabel value="Obra" title="Obra que o consumo foi cadastrado"/></td>
						<td><p:selectOneMenu value="#{consumoMB.obraSelecionada}">
								<f:selectItems value="#{consumoMB.listaObras}" />
							</p:selectOneMenu></td>
					</tr>
					
					<tr>
						<td><h:outputLabel value="Data" title="Data em que foi realizado o consumo"/></td>
						<td><p:calendar value="#{consumoMB.dataPesquisa}"  
										pattern="dd/MM/yyyy" 
										locale="pt_BR" 
										styleClass="inputDate"
										id="cal_data_consumo_pesq"
										navigator="true"
										readonlyInput="true"
										widgetVar="calendarWidget">			
										</p:calendar> </td>
						<td><p:commandLink  value="Limpar data" onclick="calendarWidget.setDate(null)"/>   
						</td>
					</tr>
					
					<tr>
						<td><p:commandButton value="Buscar"	action="#{consumoMB.pesquisar()}" ajax="false" /></td>
					</tr>
				</table>

			</p:fieldset>

			<br />

			<p:dataTable value="#{consumoMB.listEntity}" var="consumo"
				paginator="true" rows="10" paginatorPosition="bottom"
				id="table_list_consumo"
				rendered="#{consumoMB.listEntity.size() > 0}">


				<p:column>
					<f:facet name="header">
						<h:outputText value="Obra" />
					</f:facet>

					<h:outputText value="#{consumo.obra.descricao}" />

				</p:column>


				<p:column>
					<f:facet name="header">
						<h:outputText value="Última Atualização" />
					</f:facet>
					<h:outputText value="#{consumo.dataConsumo.time}">
						<f:convertDateTime pattern="dd/MM/yyyy" />
					</h:outputText>
				</p:column>

				<p:column>
					<f:facet name="header">
						<h:outputText value="Valor Consumido" />
					</f:facet>
					<h:outputText value="#{consumo.valorTotal}">
						<f:convertNumber currencySymbol="R$" type="currency" />
					</h:outputText>
				</p:column>

				<p:column>
					<f:facet name="header">
						<h:outputText value="Ação" />
					</f:facet>

					<h:commandLink action="#{consumoMB.editar()}" title="Editar">
						<f:setPropertyActionListener target="#{consumoMB.entity}"
							value="#{consumo}" />
						<h:graphicImage value="/images/editar.png"
							styleClass="buttonEditDeletSearch" />
					</h:commandLink>

				</p:column>
			</p:dataTable>
		</h:form>

	</ui:define>

</ui:composition>

</html>